/**
 * Created by dywu on 2015/9/24.
 */
angular.module('service.wxplat.config', ['ngResource'])

//manager
    .service('WxplatService', ['$resource', function ($resource) {
        // 获取验证码
        this.getcode = function (phone, success_func, error_func) {
            var GetPhoneCode = $resource(authurl + 'user/sendcode/:acount');
            var acount = "cf_linwenpin";
            GetPhoneCode.get({acount: acount, phone: phone}, success_func, error_func);
        }
        //账号登录
        this.login = function (massage, success_func, error_func) {
            var UserLogin = $resource(uc_url + 'user/login');
            return UserLogin.save(massage, success_func, error_func)
        }
        // 注册
        this.register = function (user, success_func, error_func) {
            var UserRegist = $resource(authurl + 'user');
            return UserRegist.save({code: user.code}, user, success_func, error_func);
        }
        //生成平台运营者信息
        this.operator = function (operator, success_func, error_func) {
            var UserRegist = $resource(wxoperatorurl + 'operator');
            console.log(operator)
            return UserRegist.save(operator, success_func, error_func);
        }
        //接收微信配置信息
        this.wxconfig = function (manager, success_func, error_func) {
            var UserRegist = $resource(wxconfigurl + 'wxconfig');
            console.log(manager)
            return UserRegist.save(manager, success_func, error_func);
        }
        //判断是否存在运营者
        this.checkop = function (id,success,error) {
            var checkop = $resource(wxoperatorurl + 'operator/:uid');
            return checkop.get({uid:id},success,error);
        }
        //获取账号微信菜单
        this.getwxMenuByUid = function (id,success,error) {
            var wxMenuByUid = $resource(wxconfigurl + 'wxmenu/uid/:uid');
            return wxMenuByUid.query({uid:id},success,error);
        }

    }])
;